﻿<template>
  <div class="sysDataTransfer-container">
    	<basic-container>
		<avue-crud id="table" ref="crud" v-bind="bindVal" v-on="onEvent" v-model="form" size="small"  :permission="getPermission"
			v-model:page="page" @sortable-change="sortableChange" @filter="filterChange" v-model:search="search">
			<template #menu="{row,index}" >
			    <el-button   icon="ele-StarFilled" size="small" text="" type="primary"   @click="openstartTransfer(row)">开始迁移</el-button>
             <el-button   type="warning" :icon="option.saveCustomIcon" @click="rowCustomSave(row)">{{option.saveCustomText}}</el-button>
			 <el-button   type="success" :icon="option.editCustomIcon" @click="$refs.crud.rowEdit(row,index)">{{option.editCustomText}}</el-button>
             <el-button    type="danger" :icon="option.delCustomIcon" @click="$refs.crud.rowDel(row,index)">{{option.delCustomText}}</el-button>
			</template>

			<template #menu-left="{}">
               <el-button   type="primary" :icon="option.addCustomIcon" @click="$refs.crud.rowAdd()">{{option.addCustomText}}</el-button>
			</template>
		<template #menu-right="{size}">
		<el-button v-if="option.settingBtn" 
         icon="el-icon-setting"
         circle
		 @click="pageSettingClick"
        :size="size"></el-button>

		<el-button
		v-if="option.printBtn" 
		:size="size"
		  circle
		  icon="el-icon-printer"
		  @click="customHandlePrint"
		></el-button>
        </template>

			 <template #sourceDbType="scope">
			  <el-tag>{{getEnumCodeToName(scope.row.sourceDbType, 'MyDbType')}}</el-tag>
			  </template>
				<template #sourceTableAttribute-form="{type,disabled}">
			 	  <avue-array v-model="form.sourceTableAttribute" placeholder="请输入内容"></avue-array>
				</template>
				<template #sourceOnlyTransferTables-form="{type,disabled}">
			 	  <avue-array v-model="form.sourceOnlyTransferTables" placeholder="请输入内容"></avue-array>
				</template>
				<template #sourceExcludeTables-form="{type,disabled}">
			 	  <avue-array v-model="form.sourceExcludeTables" placeholder="请输入内容"></avue-array>
				</template>
			  <template #clearTargetTableFlag="scope">
			  <el-tag v-if="scope.row.clearTargetTableFlag" type="success"> 是 </el-tag>
			  <el-tag type="danger" v-else> 否 </el-tag>
			    </template>
			 <template #targetDbType="scope">
			  <el-tag>{{getEnumCodeToName(scope.row.targetDbType, 'MyDbType')}}</el-tag>
			  </template>
			  <!-- 搜索，日期区间 -->
				<template #updateTime-search="{disabled,size}">
				<el-date-picker format="YYYY年MM月DD日" value-format="YYYY-MM-DD" :disabled="disabled" :size="size" type="daterange" v-model="search.updateTime" />
				</template>
               <!-- 编辑，日期 -->
			   	<template #updateTime-form="{type,disabled}">
			 	<avue-date v-model="form.updateTime" :disabled="disabled" :size="size"  type="datetime" format="YYYY年MM月DD日 HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"/>
				</template>
		</avue-crud>
	</basic-container>
     <startTransfer title="开始迁移" :key="timer" ref="startTransferRef"  @reloadTable="handleQuery"/>
        <el-dialog v-model="state.dialogInfoVisible" draggable width="1000px">
			<template #header>
				<div style="color: #fff">
					<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Document /> </el-icon>
					<span>详情</span>
				</div>
			</template>
			<json-viewer :value="JSON.parse(state.dialogInfoContent)" :expand-depth="8"  copyable boxed sort></json-viewer>
		</el-dialog>
	   <pageSettings
        ref="pageSettingsRef"
        title="页面配置"
        @reloadTable="handleQuery"
       />
  </div>
</template>

<script  name="sysDataTransfer">
import _ from 'lodash';
import { useRoute } from 'vue-router';
import request from '/@/utils/request';
import crudCommon from '/@/mixins/crud.js';
import pageSettings from '/@/components/common/pageSettings.vue';
import startTransfer from '/@/views/main/sysDataTransfer/component/startTransfer.vue'
	
export default crudCommon({
  components: {
    pageSettings,
		startTransfer,
  },
	props: 
	{
	 info: {},
	 callBack: { type: Function},//this.$props.callBack(参数1,......)
    },
	data: () => ({
		state:{dialogInfoVisible:false,dialogInfoContent:null},
		editSysDataTransferTitle:null,
		currenTab:{},
        tabOption:null,
	}),
	created(){
		const route = useRoute();
		this.params.frontPath = route.path;
	    if(this.tabOption!=null){
        this.currenTab=this.tabOption.column[0];
        }
	},
	methods: {
	   selectAfter(selectItems){
	   },
	   handleTabChange(column){
	       this.currenTab = column;
		   if(this.selection.length<=0)
		   this.selectAfter([]);
		   else
		   this.selectAfter(this.selection);
	   },
	  //行颜色
       tableRowClassName(every){
		 },
	   // 查看详情
       async viewDetail(row,tableName,id){
    	var url = `api/sysDataTransfer/Info/${tableName}/${id}`
    	var res = await request({url: url,method: 'get'});
    	this.state.dialogInfoContent=res.data.result;
    	this.state.dialogInfoVisible = true;
       },
	   //查看keyValue数据
	   showKeyValueInfo(list){
		if(list!=null&&list.length>0){
			if(list[0].label!=undefined){
				return list.map(r => r.label)
			}
		}
		 return list;
	    },
    openstartTransfer:_.debounce(function(row){
	this.$refs.startTransferRef.commentClick(row);},1000),
   pageSettingClick(){
   this.$refs.pageSettingsRef.commentClick(this.option);
   },
	
}}, {
path: '/main/sysDataTransfer/index',
name: 'main/sysDataTransfer', //模块名字
list: 'pageSysDataTransfer', //列表接口名字
update: 'updateSysDataTransfer', //更新接口名字
add: 'addSysDataTransfer', //新增接口名字
del: 'deleteSysDataTransfer', //删除接口名字
save:'saveSysDataTransfer', //保存接口
rowKey: 'id', //主键
pageNumber: 'Page', //页码
pageSize: 'PageSize', //页数
res: (data) => {
return {
total: 0,
data: []
}
}, //列表的结构
total: 'total', //总页数
data: 'list' //列表属性
})
</script>
<style scoped lang='scss'>
	.formClassName {
		padding: 0px 0px 10px;
	}
	.avue-dialog__footer {
		padding: 0px 0px !important;
	}
	@import url('../../../../public/css/iconfont.css');
	@import url('../../../../public/css/iconshine.css');
	@import url('../../../../public/css/linecolor.css');
</style>

